<?php
class ApiModel extends Model {
	
	//自动填充内容  addtime
	protected $_auto   =   array(
		array('addtime','time',1,'function'),//add添加的时候自动填充
		array('appid','create_id',1,'function'),
		array('appkey','create_id',1,'function')
		//array('solevar','create_id',1,'function'),
	);
	
	
	public function getApiNodeHtml($arr,$view){
		
		$html = '';
		$lang = LANG_SET;
		
		foreach($arr as $k=>$v){
			
			$html .= '<p class="p1">'.$v['lang'][$lang].'</p>';
			$html .= '<div>';
			
			foreach($v['child'] as $n=>$m){
					
				$html .= '<p class="p2">'.$m['lang'][$lang].'</p>';
				$html .= '<div class="tab_deal_check">';
				
				foreach($m['child'] as $j=>$p){
					
					$map['forid']  = $view['id'];
					$map['appid']  = $view['appid'];
					$map['module'] = $n;
					$map['action'] = $j;
					$data = M('ApiAccess')->where($map)->find();
					
					if($data['id']){
						$html .= '<input type="checkbox" value="1" checked name="chk['.$n.']['.$j.']">'.$p['lang'][$lang];
					}else{
						$html .= '<input type="checkbox" value="1" name="chk['.$n.']['.$j.']">'.$p['lang'][$lang];
					}
					
					if($data['visit_times']){
						$html .= '<input type="text" class="form_text" value="'.$data['visit_times'].'" name="visit['.$n.']['.$j.']">';
					}else{
						$html .= '<input type="text" class="form_text" value="0" name="visit['.$n.']['.$j.']">';
					}
					
				}
				$html .= '</div>';
			}
			$html .= '</div>';
		}
		
		return $html;
	}
	
}
?>